package me.leon.keeplive

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log

class SystemReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        when (intent.action) {
            "android.intent.action.BOOT_COMPLETED" -> {
                Log.d("SystemReceiver", "${context.packageName}  BOOT_COMPLETED")
                context.startActivity(
                    context.packageManager.getLaunchIntentForPackage(context.packageName)?.apply {
                        setPackage(null)
                    }
                )
            }
            Intent.ACTION_USER_PRESENT -> {
                Log.d("SystemReceiver", "${context.packageName}  ACTION_USER_PRESENT")
            }
        }
    }
}
